Skip to content

Fix 500 reading uploaded addon file in text mode#48

Merged
joefarrelly merged 1 commit into
devfrom
fix-addon-file-read-text-mode
Jun 30, 2026
Merged

Fix 500 reading uploaded addon file in text mode#48
joefarrelly merged 1 commit into
devfrom
fix-addon-file-read-text-mode

Conversation

@joefarrelly

Copy link
Copy Markdown
Owner

Summary

  • ProfileUserView.list opened the stored .lua file with user_obj.user_file.open("r") (text mode), so f.readlines() already returned str lines, and the subsequent line.decode("utf-8") call crashed with AttributeError: 'str' object has no attribute 'decode'.
  • This code path existed before page=addon (PR Serve gold and played time from cached addon file #46) but was never exercised in practice, since nothing previously called ?page= with anything other than header. Fixed by opening in binary mode ("rb"), matching what the decode call expects.

Test plan

  • Added a regression test that uploads a file then reads it back via page=addon; reproduces the exact AttributeError against the pre-fix code and passes against the fix
  • pytest tests/ (35 passed)
  • ruff check

ProfileUserView.list opened the stored .lua file with mode "r" (text),
so readlines() already returned str, and the subsequent .decode("utf-8")
call crashed. This path was previously unreachable in practice (no page
read the file before page=addon was added) so the bug went unnoticed.
@joefarrelly joefarrelly enabled auto-merge (squash) June 30, 2026 23:02
@joefarrelly joefarrelly merged commit 593e2cc into dev Jun 30, 2026
3 checks passed
@joefarrelly joefarrelly deleted the fix-addon-file-read-text-mode branch June 30, 2026 23:02
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants